import { ecs } from "db://oops-framework/libs/ecs/ECS";
import { Scene } from "../Scene";
import { oops } from "db://oops-framework/core/Oops";
import { BattleEventTrigger } from "../../skill/bll/utils/BattleEventTrigger";
import { BattleType } from "../SceneEvent";

/**
 * 回合结束
 */
@ecs.register('RoundEnd')
export class RoundEndComp extends ecs.Comp {
    reset() {

    }
}

export class RoundEndSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
    filter(): ecs.IMatcher {
        return ecs.allOf(RoundEndComp);
    }

    entityEnter(e: Scene): void {
        // 回合数递增
        let mmr = e.MapModelRole;
        mmr.round++;
        // 更新战场所有角色行动状态为可行动
        mmr.roles.forEach(role => {
            // 回合结束更新所有角色身上的BUFF状态
         //   RoleBuff.update(role);

            role.RoleModel.active = false;
        });
        // 触发技能战报
        BattleEventTrigger.onRoundEnd(BattleType.Scene);

        oops.log.trace(`<<第${e.MapModelRole.round - 1}回合>>结束`);
        e.roundStart();
        e.remove(RoundEndComp);
    }
}